<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');
class tinhluong_Controller extends Controller {
    function __construct(){
        parent::__construct('quanlyluong', 'tinhluong');
        $this->check_login();
        $this->view->template->menu_html =$this->CREATE_MENU();
        $this->view->template->nhacviec_html =$this->CREATE_NHAC_VIEC(); 
        $this->CHECK_QUYEN('quanlyluong', 'tinhluong');
    }
    function main(){
        $this->dsp_all_tinhluong();
    }
    /****************************form canbo***********************/
    private function _save_filter(){
        $v_NAM= $this->get_post_var('cbx_NAM');
        $v_THANG= $this->get_post_var('cbx_THANG');
        if($v_THANG == '' && $v_NAM == ''){
           $v_NAM = date('Y');
           $v_THANG = date('m');
           if($v_THANG==1){
                $v_THANG=12;
                $v_NAM=$v_NAM-1;
           }else {
                $v_THANG=$v_THANG-1;
                $v_NAM=$v_NAM;
           }
        }
        return array(
            'cbx_NAM'=> $v_NAM,
            'cbx_THANG'=> $v_THANG,
        );
    }
    function dsp_all_tinhluong(){
        $arr_filter = $this-> _save_filter();
        $VIEW_DATA['arr_filter']       = $arr_filter;
        $VIEW_DATA['arr_all_tinhluong']= $this->model->SELECT_BANG_LUONG($arr_filter);
        $VIEW_DATA['arr_all_trangthaithangluong']= $this->model->SELECT_TRANG_THAI_THANG_LUONG($arr_filter);
        $this->view->render('dsp_all_tinhluong', $VIEW_DATA);
    }
    public function tinh_luong(){
        $this->model->goback_url = $this->view->get_controller_url();
        $this->model->tinh_luong();
    }
    public function capnhat_luong(){
        $this->model->goback_url = $this->view->get_controller_url();
        $this->model->capnhat_luong();
    }
    public function khoa_luong(){
        $this->model->goback_url = $this->view->get_controller_url();
        $this->model->khoa_luong();
    }
    function dsp_inbangluong(){
        $P_THANG_LANH_LUONG = replace_bad_char($_REQUEST['thanglanhluong']);
        $P_NAM_LANH_LUONG = replace_bad_char($_REQUEST['namlanhluong']);
        $VIEW_DATA['var_thanglanhluong']= $P_THANG_LANH_LUONG;
        $VIEW_DATA['var_namlanhluong']= $P_NAM_LANH_LUONG;
        $VIEW_DATA['arr_all_tinhluong']= $this->model->SELECT_BANG_LUONG2($P_THANG_LANH_LUONG,$P_NAM_LANH_LUONG);
        $this->view->render('dsp_inbangluong',$VIEW_DATA);
    }
}
